import 'dart:io';

//import 'package:amap_base/amap_base.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:jpush_flutter/jpush_flutter.dart';
import 'package:wanchong/app/app.dart';

void main() {
  ///初始化jpush
  initJpush();
  runApp(App());
  if (Platform.isAndroid) {
    SystemUiOverlayStyle systemUiOverlayStyle = SystemUiOverlayStyle(
        statusBarColor: Colors.transparent,
        statusBarIconBrightness: Brightness.dark);
    SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle);
  }
  if (Platform.isIOS) {
    // AMapLocationClient.setApiKey("你的key");
    initAmap();
  }
}

initAmap() async {
  //await AMap.init("38ef56f50adc3906dff4693ac12c44ef");
}

initJpush() async{
  var jpush = JPush();
  jpush.applyPushAuthority(
      new NotificationSettingsIOS(sound: true, alert: true, badge: true));
  jpush.addEventHandler(
    // 接收通知回调方法。
    onReceiveNotification: (Map<String, dynamic> message) async {
      print("flutter onReceiveNotification: $message");
    },
    // 点击通知回调方法。
    onOpenNotification: (Map<String, dynamic> message) async {
      print("flutter onOpenNotification: $message");
    },
    // 接收自定义消息回调方法。
    onReceiveMessage: (Map<String, dynamic> message) async {
      print("flutter onReceiveMessage: $message");
    },
  );
  jpush.getRegistrationID().then((rid) => print(rid));
  jpush.setup(
    appKey: "a3e9bb2e5877c4a99ac9d5b3",
    channel: "theChannel",
    production: false,
    debug: true, // 设置是否打印 debug 日志
  );
  jpush.applyPushAuthority(new NotificationSettingsIOS(
      sound: true,
      alert: true,
      badge: true));
}
